package com.bbm.controller;

import com.bbm.entity.User;
import com.bbm.entity.vo.ResponseResult;
import com.bbm.service.LoginService;
import com.bbm.service.UserService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : lyj
 * @Timer : 2024/3/14
 * @Description :
 */
@RestController
@RequestMapping("user")
public class LoginController {

    @Resource
    private LoginService loginService;


    @PostMapping(  "/login")
    public ResponseResult login(@RequestParam("username")String username,
                                @RequestParam("password")String password) {
        return loginService.login(username,password);
    }

    @PostMapping("/ad_login")
    public ResponseResult loginAdmin(@RequestBody User user) {
        return loginService.loginAdmin(user);
    }


    @GetMapping("/info")
    public ResponseResult getUserInfo(@RequestParam String username) {
        return loginService.getUserInfo(username);
    }

    @RequestMapping(value = "/req", method = RequestMethod.POST)
    public String reqPost(){
        System.out.println("获取到post请求，服务器被访问......");
        return "mainPost";
    }

    @PostMapping("/register")
    public ResponseResult register(@RequestBody User user) {
        return loginService.register(user);
    }


}
